package com.snail.poker.web.bean;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.snail.poker.web.PageContext;

/**
 * 分页数据传输对象
 * 
 * @author 黄珍辉
 * 
 */
public class PageBean {
	private int total;
	private List<?> datas;
	private int pageSize;

	@JSON(name = "rows")
	public List<?> getDatas() {
		return datas;
	}

	public void setDatas(List<?> datas) {
		this.datas = datas;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getPageSize() {
		if (this.total < 0) {
			this.setPageSize(0);
		}
		try {
			this.setPageSize(this.total / PageContext.getPageSize() + 1);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return this.pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
}